package com.cheng.im.gateway.protobuilder;

import com.cheng.im.common.constants.ProtoInstants;
import com.cheng.im.common.bean.msg.ProtoMsgV1;
import org.springframework.stereotype.Service;

@Service("ChatResponseBuilder")
public class ChatResponseBuilder {

    public ProtoMsgV1.Message chatResponse(long seqId, ProtoInstants.ResultCodeEnum en) {
        ProtoMsgV1.Message.Builder mb = ProtoMsgV1.Message.newBuilder()
                .setType(ProtoMsgV1.HeadType.MESSAGE_RESPONSE)  //设置消息类型
                .setSequence(seqId);                 //设置应答流水，与请求对应

        ProtoMsgV1.MessageResponse.Builder rb =
                ProtoMsgV1.MessageResponse.newBuilder()
                        .setCode(en.getCode())
                        .setInfo(en.getDesc())
                        .setExpose(1);
        mb.setMessageResponse(rb.build());
        return mb.build();
    }
}
